<template>
	<view>
		<!-- <u-navbar title="支付"></u-navbar> -->
		<view class="u-padding-30">
			<!-- <u-input v-model="recoveryOrder.total" type="digit" :border="true" /> -->
			<view class="u-margin-top-30">
				<u-button text="支付" @click="pay"></u-button>
			</view>
		</view>
	</view>
</template>

<script>
	import { payOrder } from '@/common/http.api.js';
	export default {
		data() {
			return {
				// recoveryOrder:{
				// 	total:0.01,
				// 	orderNumber:new Date().getTime(),
				// 	userId:133,
				// 	// userId:137,
				// }
			}
		},
		methods: {
			pay(){
				let recoveryOrder = {
					outTradeNo: "2021072210272348776387143404481",
					openId: "oCOo75KJFRd237YHTmMG93aTfM-0"
				}
				payOrder(recoveryOrder).then((res) => {
					let data = JSON.parse(res);
					uni.requestPayment({
					    provider: 'wxpay',
					    timeStamp:  data.timeStamp,
					    nonceStr: data.nonceStr,
					    package: data.package,
					    signType: 'MD5',
					    paySign: data.paySign,
					    success: function (res) {
					        console.log('success:' + JSON.stringify(res));
					    },
					    fail: function (err) {
					        console.log('fail:' + JSON.stringify(err));
					    }
					});
				}).catch(() =>{
				})
			}
		}
	}
</script>

<style>

</style>
